<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <!-- <meta name="viewport" content="width=scr, initial-scale=1.0"> -->
    <title>Document</title>
</head>
<body>
    <!--把其他类型转换数字模型 -->
        <script>

            let  str = "123456"
            // parseint（）取整
            console.log(parseInt (str));
            console.log(parseInt (15.2));
            console.log(parseInt ('15A'));
            console.log(typeof parseInt('A15'));   // NaN
            console.log(typeof parseInt ('A15'));//Number


            //  判断是不是NAN
            // isNAN
            let  cqb = parseInt("a456")
            // isNAN(要写被检测的数据)
            console.log(isNaN(cqb));
            // 浮转点数
            // parseFloat()转小数
            console.log(parseFloat(15.2));
            console.log(parseFloat('15.2ansfl123456'));  
            console.log(parseFloat('a15.2ansfl123456'));   // NaN

            // 使用Number()  转换比较严格
            console.log(Number(15.2));
            console.log(Number('15.2ansfl123456'));    // NaN
            console.log(Number('a15.2ansfl123456'));   // NaN

            console.log(Number(true));   //1
            console.log(Number(false))   //0
            console.log(Number(undefined));   // NaN

            // 字符串的转化
            let numl = 123456
            let nu1  = null
            // null和nudefined   不可以使用toString
            // console.log(nu1.toString());

            // .toString(进制)
            // .toString(8) 8进制
            console.log(num1.toString());

            // String:不可以转换进制
            console.log(String(num1));
            console.log(String(num1));

            // 布尔值的转换
            // 不存在的，不合理的都是flase

            console.log(Boolean(1));// ture
            console.log(Boolean(-1));// ture
            console.log(Boolean(0));// false

            console.log(Boolean('好机会'));// ture
            console.log(Boolean(''));// false
            console.log(Boolean(' '));// ture

            console.log(Boolean(null));// flase
            console.log(Boolean(undefined));// flase
            console.log(Boolean(NaN));// flase
            
        </script>
</body>
</html>